home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / toolkit / vbof_v11 / democust.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-03-01  |  34.5 KB  |  1,060 lines

  1. VERSION 4.00
  2. Begin VB.Form CustomerDetailsDataControl 
  3.    Caption         =   "Customer Details (Supports the DataControl within the VBObjectFrameWorkCollection)"
  4.    ClientHeight    =   6000
  5.    ClientLeft      =   75
  6.    ClientTop       =   330
  7.    ClientWidth     =   8865
  8.    Height          =   6420
  9.    Left            =   15
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6000
  12.    ScaleWidth      =   8865
  13.    Top             =   -30
  14.    Width           =   8985
  15.    Begin VB.Data Data3 
  16.       Caption         =   "Data3"
  17.       Connect         =   "Access"
  18.       DatabaseName    =   "DemoVBFW.mdb"
  19.       Exclusive       =   0   'False
  20.       Height          =   300
  21.       Left            =   8040
  22.       Options         =   0
  23.       ReadOnly        =   -1  'True
  24.       RecordsetType   =   1  'Dynaset
  25.       RecordSource    =   "Phones"
  26.       Top             =   1920
  27.       Visible         =   0   'False
  28.       Width           =   1140
  29.    End
  30.    Begin VB.CommandButton pbOK 
  31.       Cancel          =   -1  'True
  32.       Caption         =   "OK"
  33.       Default         =   -1  'True
  34.       Height          =   375
  35.       Left            =   7800
  36.       TabIndex        =   11
  37.       Top             =   2280
  38.       Width           =   975
  39.    End
  40.    Begin VB.CommandButton pbDeleteCustomer 
  41.       Caption         =   "Delete"
  42.       Height          =   375
  43.       Left            =   7800
  44.       TabIndex        =   10
  45.       Top             =   1200
  46.       Width           =   975
  47.    End
  48.    Begin VB.CommandButton pbUpdateCustomer 
  49.       Caption         =   "Update"
  50.       Height          =   375
  51.       Left            =   7800
  52.       TabIndex        =   9
  53.       Top             =   720
  54.       Width           =   975
  55.    End
  56.    Begin VB.CommandButton pbAddNewCustomer 
  57.       Caption         =   "Add New"
  58.       Height          =   375
  59.       Left            =   7800
  60.       TabIndex        =   8
  61.       Top             =   240
  62.       Width           =   975
  63.    End
  64.    Begin VB.Frame Frame1 
  65.       Caption         =   "Customer Details"
  66.       Height          =   2535
  67.       Left            =   4440
  68.       TabIndex        =   31
  69.       Top             =   120
  70.       Width           =   3255
  71.       Begin VB.ComboBox lbxGenderCodes 
  72.          Height          =   315
  73.          Left            =   2400
  74.          Sorted          =   -1  'True
  75.          TabIndex        =   7
  76.          Top             =   2160
  77.          Width           =   615
  78.       End
  79.       Begin VB.ComboBox lbxMaritalStatusCodes 
  80.          Height          =   315
  81.          Left            =   1200
  82.          Sorted          =   -1  'True
  83.          TabIndex        =   6
  84.          Top             =   2160
  85.          Width           =   855
  86.       End
  87.       Begin VB.TextBox efCustomerNumber 
  88.          Height          =   285
  89.          Left            =   1200
  90.          TabIndex        =   1
  91.          Top             =   360
  92.          Width           =   1815
  93.       End
  94.       Begin VB.TextBox efDateOfBirth 
  95.          Height          =   285
  96.          Left            =   1200
  97.          TabIndex        =   5
  98.          Top             =   1800
  99.          Width           =   1815
  100.       End
  101.       Begin VB.TextBox efFirstName 
  102.          Height          =   285
  103.          Left            =   1200
  104.          TabIndex        =   2
  105.          Top             =   720
  106.          Width           =   1815
  107.       End
  108.       Begin VB.TextBox efLastName 
  109.          Height          =   285
  110.          Left            =   1200
  111.          TabIndex        =   3
  112.          Top             =   1080
  113.          Width           =   1815
  114.       End
  115.       Begin VB.TextBox efSSN 
  116.          Height          =   285
  117.          Left            =   1200
  118.          TabIndex        =   4
  119.          Top             =   1440
  120.          Width           =   1815
  121.       End
  122.       Begin VB.Label Label1 
  123.          Caption         =   "Cust Number"
  124.          Height          =   255
  125.          Index           =   12
  126.          Left            =   120
  127.          TabIndex        =   38
  128.          Top             =   360
  129.          Width           =   975
  130.       End
  131.       Begin VB.Label Label1 
  132.          Caption         =   "Sex"
  133.          Height          =   255
  134.          Index           =   11
  135.          Left            =   2040
  136.          TabIndex        =   37
  137.          Top             =   2160
  138.          Width           =   375
  139.       End
  140.       Begin VB.Label Label1 
  141.          Caption         =   "Marital Status"
  142.          Height          =   255
  143.          Index           =   4
  144.          Left            =   120
  145.          TabIndex        =   36
  146.          Top             =   2160
  147.          Width           =   975
  148.       End
  149.       Begin VB.Label Label1 
  150.          Caption         =   "Date Of Birth"
  151.          Height          =   255
  152.          Index           =   3
  153.          Left            =   120
  154.          TabIndex        =   35
  155.          Top             =   1800
  156.          Width           =   975
  157.       End
  158.       Begin VB.Label Label1 
  159.          Caption         =   "First Name"
  160.          Height          =   255
  161.          Index           =   0
  162.          Left            =   120
  163.          TabIndex        =   34
  164.          Top             =   720
  165.          Width           =   975
  166.       End
  167.       Begin VB.Label Label1 
  168.          Caption         =   "Last Name"
  169.          Height          =   255
  170.          Index           =   1
  171.          Left            =   120
  172.          TabIndex        =   33
  173.          Top             =   1080
  174.          Width           =   975
  175.       End
  176.       Begin VB.Label Label1 
  177.          Caption         =   "SSN"
  178.          Height          =   255
  179.          Index           =   2
  180.          Left            =   120
  181.          TabIndex        =   32
  182.          Top             =   1440
  183.          Width           =   975
  184.       End
  185.    End
  186.    Begin VB.Data Data2 
  187.       Caption         =   "Data2"
  188.       Connect         =   "Access"
  189.       DatabaseName    =   "DemoVBFW.mdb"
  190.       Exclusive       =   0   'False
  191.       Height          =   300
  192.       Left            =   8040
  193.       Options         =   0
  194.       ReadOnly        =   -1  'True
  195.       RecordsetType   =   1  'Dynaset
  196.       RecordSource    =   "Addresses"
  197.       Top             =   1680
  198.       Visible         =   0   'False
  199.       Width           =   1140
  200.    End
  201.    Begin VB.Data Data1 
  202.       Caption         =   "Data1"
  203.       Connect         =   "Access"
  204.       DatabaseName    =   "DemoVBFW.mdb"
  205.       Exclusive       =   0   'False
  206.       Height          =   300
  207.       Left            =   8040
  208.       Options         =   0
  209.       ReadOnly        =   -1  'True
  210.       RecordsetType   =   1  'Dynaset
  211.       RecordSource    =   "Persons"
  212.       Top             =   1440
  213.       Visible         =   0   'False
  214.       Width           =   1140
  215.    End
  216.    Begin TabDlg.SSTab SSTab1 
  217.       Height          =   3135
  218.       Left            =   120
  219.       TabIndex        =   12
  220.       Top             =   2760
  221.       Width           =   8775
  222.       _Version        =   65536
  223.       _ExtentX        =   15478
  224.       _ExtentY        =   5530
  225.       _StockProps     =   15
  226.       Caption         =   "Phones"
  227.       TabsPerRow      =   2
  228.       Tab             =   1
  229.       TabOrientation  =   0
  230.       Tabs            =   2
  231.       Style           =   1
  232.       TabMaxWidth     =   0
  233.       TabHeight       =   529
  234.       TabCaption(0)   =   "Addresses"
  235.       Tab(0).ControlCount=   7
  236.       Tab(0).ControlEnabled=   0   'False
  237.       Tab(0).Control(0)=   "pbAddNewAddress"
  238.       Tab(0).Control(1)=   "pbUpdateAddress"
  239.       Tab(0).Control(2)=   "pbDeleteAddress"
  240.       Tab(0).Control(3)=   "Frame2"
  241.       Tab(0).Control(4)=   "efFormattedAddress"
  242.       Tab(0).Control(5)=   "Label1(13)"
  243.       Tab(0).Control(6)=   "DBGrid2"
  244.       TabCaption(1)   =   "Phones"
  245.       Tab(1).ControlCount=   7
  246.       Tab(1).ControlEnabled=   -1  'True
  247.       Tab(1).Control(0)=   "DBGrid3"
  248.       Tab(1).Control(1)=   "Label1(21)"
  249.       Tab(1).Control(2)=   "efFormattedPhoneNumber"
  250.       Tab(1).Control(3)=   "Frame3"
  251.       Tab(1).Control(4)=   "pbDeletePhone"
  252.       Tab(1).Control(5)=   "pbUpdatePhone"
  253.       Tab(1).Control(6)=   "pbAddPhone"
  254.       Begin VB.CommandButton pbAddPhone 
  255.          Caption         =   "Add New"
  256.          Height          =   375
  257.          Left            =   7680
  258.          TabIndex        =   28
  259.          Top             =   480
  260.          Width           =   975
  261.       End
  262.       Begin VB.CommandButton pbUpdatePhone 
  263.          Caption         =   "Update"
  264.          Height          =   375
  265.          Left            =   7680
  266.          TabIndex        =   29
  267.          Top             =   960
  268.          Width           =   975
  269.       End
  270.       Begin VB.CommandButton pbDeletePhone 
  271.          Caption         =   "Delete"
  272.          Height          =   375
  273.          Left            =   7680
  274.          TabIndex        =   30
  275.          Top             =   1440
  276.          Width           =   975
  277.       End
  278.       Begin VB.Frame Frame3 
  279.          Caption         =   "Address Details"
  280.          Height          =   2655
  281.          Left            =   4320
  282.          TabIndex        =   50
  283.          Top             =   360
  284.          Width           =   3255
  285.          Begin VB.TextBox efUsage 
  286.             Height          =   285
  287.             Left            =   1200
  288.             TabIndex        =   27
  289.             Top             =   720
  290.             Width           =   1815
  291.          End
  292.          Begin VB.TextBox efPhoneNumber 
  293.             Height          =   285
  294.             Left            =   1200
  295.             TabIndex        =   26
  296.             Top             =   360
  297.             Width           =   1815
  298.          End
  299.          Begin VB.Label Label1 
  300.             Caption         =   "Usage"
  301.             Height          =   255
  302.             Index           =   16
  303.             Left            =   120
  304.             TabIndex        =   52
  305.             Top             =   720
  306.             Width           =   975
  307.          End
  308.          Begin VB.Label Label1 
  309.             Caption         =   "Phone Num"
  310.             Height          =   255
  311.             Index           =   15
  312.             Left            =   120
  313.             TabIndex        =   51
  314.             Top             =   360
  315.             Width           =   975
  316.          End
  317.       End
  318.       Begin VB.CommandButton pbAddNewAddress 
  319.          Caption         =   "Add New"
  320.          Height          =   375
  321.          Left            =   -67320
  322.          TabIndex        =   22
  323.          Top             =   480
  324.          Width           =   975
  325.       End
  326.       Begin VB.CommandButton pbUpdateAddress 
  327.          Caption         =   "Update"
  328.          Height          =   375
  329.          Left            =   -67320
  330.          TabIndex        =   23
  331.          Top             =   960
  332.          Width           =   975
  333.       End
  334.       Begin VB.CommandButton pbDeleteAddress 
  335.          Caption         =   "Delete"
  336.          Height          =   375
  337.          Left            =   -67320
  338.          TabIndex        =   24
  339.          Top             =   1440
  340.          Width           =   975
  341.       End
  342.       Begin VB.Frame Frame2 
  343.          Caption         =   "Address Details"
  344.          Height          =   2655
  345.          Left            =   -70680
  346.          TabIndex        =   39
  347.          Top             =   360
  348.          Width           =   3255
  349.          Begin VB.ComboBox lbxStateCodes 
  350.             Height          =   315
  351.             Left            =   1200
  352.             Sorted          =   -1  'True
  353.             TabIndex        =   18
  354.             Top             =   1800
  355.             Width           =   1815
  356.          End
  357.          Begin VB.TextBox efLine1 
  358.             Height          =   285
  359.             Left            =   1200
  360.             TabIndex        =   14
  361.             Top             =   360
  362.             Width           =   1815
  363.          End
  364.          Begin VB.TextBox efLine2 
  365.             Height          =   285
  366.             Left            =   1200
  367.             TabIndex        =   15
  368.             Top             =   720
  369.             Width           =   1815
  370.          End
  371.          Begin VB.TextBox efLine3 
  372.             Height          =   285
  373.             Left            =   1200
  374.             TabIndex        =   16
  375.             Top             =   1080
  376.             Width           =   1815
  377.          End
  378.          Begin VB.TextBox efCity 
  379.             Height          =   285
  380.             Left            =   1200
  381.             TabIndex        =   17
  382.             Top             =   1440
  383.             Width           =   1815
  384.          End
  385.          Begin VB.TextBox efZipCode 
  386.             Height          =   285
  387.             Left            =   1200
  388.             MaxLength       =   5
  389.             TabIndex        =   19
  390.             Top             =   2160
  391.             Width           =   735
  392.          End
  393.          Begin VB.TextBox efZipExtension 
  394.             Height          =   285
  395.             Left            =   2640
  396.             MaxLength       =   2
  397.             TabIndex        =   21
  398.             Top             =   2160
  399.             Width           =   375
  400.          End
  401.          Begin VB.TextBox efZipSupplement 
  402.             Height          =   285
  403.             Left            =   2040
  404.             MaxLength       =   4
  405.             TabIndex        =   20
  406.             Top             =   2160
  407.             Width           =   495
  408.          End
  409.          Begin VB.Label Label1 
  410.             Caption         =   "Line 1"
  411.             Height          =   255
  412.             Index           =   5
  413.             Left            =   120
  414.             TabIndex        =   45
  415.             Top             =   360
  416.             Width           =   975
  417.          End
  418.          Begin VB.Label Label1 
  419.             Caption         =   "Line 2"
  420.             Height          =   255
  421.             Index           =   6
  422.             Left            =   120
  423.             TabIndex        =   44
  424.             Top             =   720
  425.             Width           =   975
  426.          End
  427.          Begin VB.Label Label1 
  428.             Caption         =   "Line 3"
  429.             Height          =   255
  430.             Index           =   7
  431.             Left            =   120
  432.             TabIndex        =   43
  433.             Top             =   1080
  434.             Width           =   975
  435.          End
  436.          Begin VB.Label Label1 
  437.             Caption         =   "City"
  438.             Height          =   255
  439.             Index           =   10
  440.             Left            =   120
  441.             TabIndex        =   42
  442.             Top             =   1440
  443.             Width           =   975
  444.          End
  445.          Begin VB.Label Label1 
  446.             Caption         =   "State"
  447.             Height          =   255
  448.             Index           =   8
  449.             Left            =   120
  450.             TabIndex        =   41
  451.             Top             =   1800
  452.             Width           =   975
  453.          End
  454.          Begin VB.Label Label1 
  455.             Caption         =   "Zip Code"
  456.             Height          =   255
  457.             Index           =   9
  458.             Left            =   120
  459.             TabIndex        =   40
  460.             Top             =   2160
  461.             Width           =   975
  462.          End
  463.       End
  464.       Begin VB.Label efFormattedPhoneNumber 
  465.          BorderStyle     =   1  'Fixed Single
  466.          ForeColor       =   &H00FF0000&
  467.          Height          =   255
  468.          Left            =   120
  469.          TabIndex        =   54
  470.          Top             =   2760
  471.          Width           =   4095
  472.       End
  473.       Begin VB.Label Label1 
  474.          Caption         =   "Formatted Phone"
  475.          Height          =   255
  476.          Index           =   21
  477.          Left            =   120
  478.          TabIndex        =   53
  479.          Top             =   2520
  480.          Width           =   1575
  481.       End
  482.       Begin MSDBGrid.DBGrid DBGrid3 
  483.          Bindings        =   "DemoCust.frx":0000
  484.          Height          =   1935
  485.          Left            =   120
  486.          OleObjectBlob   =   "DemoCust.frx":000E
  487.          TabIndex        =   25
  488.          Top             =   480
  489.          Width           =   4095
  490.       End
  491.       Begin VB.Label efFormattedAddress 
  492.          BorderStyle     =   1  'Fixed Single
  493.          ForeColor       =   &H00FF0000&
  494.          Height          =   975
  495.          Left            =   -74880
  496.          TabIndex        =   47
  497.          Top             =   2040
  498.          Width           =   4095
  499.       End
  500.       Begin VB.Label Label1 
  501.          Caption         =   "Formatted Address"
  502.          Height          =   255
  503.          Index           =   13
  504.          Left            =   -74880
  505.          TabIndex        =   46
  506.          Top             =   1800
  507.          Width           =   1575
  508.       End
  509.       Begin MSDBGrid.DBGrid DBGrid2 
  510.          Bindings        =   "DemoCust.frx":08E2
  511.          Height          =   1215
  512.          Left            =   -74880
  513.          OleObjectBlob   =   "DemoCust.frx":08F0
  514.          TabIndex        =   13
  515.          Top             =   480
  516.          Width           =   4095
  517.       End
  518.    End
  519.    Begin VB.Label efAge 
  520.       BorderStyle     =   1  'Fixed Single
  521.       ForeColor       =   &H00FF0000&
  522.       Height          =   255
  523.       Left            =   3720
  524.       TabIndex        =   56
  525.       Top             =   2400
  526.       Width           =   615
  527.    End
  528.    Begin VB.Label Label1 
  529.       Caption         =   "Age"
  530.       Height          =   255
  531.       Index           =   17
  532.       Left            =   3720
  533.       TabIndex        =   55
  534.       Top             =   2160
  535.       Width           =   375
  536.    End
  537.    Begin VB.Label Label1 
  538.       Caption         =   "Formatted Name"
  539.       Height          =   255
  540.       Index           =   14
  541.       Left            =   120
  542.       TabIndex        =   49
  543.       Top             =   2160
  544.       Width           =   1575
  545.    End
  546.    Begin VB.Label efFormattedName 
  547.       BorderStyle     =   1  'Fixed Single
  548.       ForeColor       =   &H00FF0000&
  549.       Height          =   255
  550.       Left            =   120
  551.       TabIndex        =   48
  552.       Top             =   2400
  553.       Width           =   3495
  554.    End
  555.    Begin MSDBGrid.DBGrid DBGrid1 
  556.       Bindings        =   "DemoCust.frx":0FF8
  557.       Height          =   1935
  558.       Left            =   120
  559.       OleObjectBlob   =   "DemoCust.frx":1006
  560.       TabIndex        =   0
  561.       Top             =   120
  562.       Width           =   4215
  563.    End
  564. Attribute VB_Name = "CustomerDetailsDataControl"
  565. Attribute VB_Creatable = False
  566. Attribute VB_Exposed = False
  567. Option Explicit
  568. ' This example show how the VBOFW can
  569. '   support the VB application through conventional
  570. '   VB programming techniques, including the use of
  571. '   the VB DataControl, via the
  572. '   VBOFWDataWrapper
  573. Private pvtCurrentPerson As Person
  574. Private pvtPersonsDataWrapper As VBOFDataWrapper
  575. Private pvtCurrentAddress As Address
  576. Private pvtAddressesDataWrapper As VBOFDataWrapper
  577. Private pvtCurrentPhone As Phone
  578. Private pvtPhonesDataWrapper As VBOFDataWrapper
  579. Private pvtStates As VBOFCollection
  580. Private pvtStatesListBoxWrapper As VBOFListBoxWrapper
  581. Private pvtGenderCodes As VBOFCollection
  582. Private pvtGenderCodesListBoxWrapper As VBOFListBoxWrapper
  583. Private pvtMaritalStatusCodes As VBOFCollection
  584. Private pvtMaritalStatusCodesListBoxWrapper As VBOFListBoxWrapper
  585. Public ObjectManager As VBOFObjectManager
  586. Private Sub PopulateGenderCodes()
  587. ' instantiate pvtGenderCodes as a
  588. '   reference to pvtGenderCodes
  589.     Set pvtGenderCodes = _
  590.         pubGenderCodes
  591. ' attach the Collection, ListBox and ListBoxWrapper
  592.     Set pvtGenderCodesListBoxWrapper = _
  593.         ObjectManager. _
  594.             NewVBOFListBoxWrapper( _
  595.             Collection:=pvtGenderCodes, _
  596.             ListBox:=lbxGenderCodes)
  597.     pvtGenderCodesListBoxWrapper. _
  598.         AddItems
  599. End Sub
  600. Private Sub PopulateMaritalStatusCodes()
  601. ' instantiate pvtMaritalStatusCodes as a
  602. '   reference to pubMaritalStatusCodes
  603.     Set pvtMaritalStatusCodes = _
  604.         pubMaritalStatusCodes
  605. ' attach the Collection, ListBox and ListBoxWrapper
  606.     Set pvtMaritalStatusCodesListBoxWrapper = _
  607.         ObjectManager. _
  608.             NewVBOFListBoxWrapper( _
  609.             Collection:=pvtMaritalStatusCodes, _
  610.             ListBox:=lbxMaritalStatusCodes)
  611.     pvtMaritalStatusCodesListBoxWrapper. _
  612.         AddItems
  613. End Sub
  614. Public Sub ObjectEventCallBack(Optional Event As Variant, Optional Object As Variant)
  615.     Dim tempObjectType As String
  616.     Dim tempUCaseEvent As String
  617.     On Local Error Resume Next
  618.     tempObjectType = TypeName(Object)
  619.     tempUCaseEvent = UCase$(Event)
  620.     If tempObjectType = "Person" Then
  621.         
  622.         If tempUCaseEvent = "REMOVEDITEM" _
  623.         Or tempUCaseEvent = "REPLACEDITEM" _
  624.         Then
  625.             pvtPersonsDataWrapper.Refresh
  626.             
  627.             If Object.ObjectID = pvtCurrentPerson.ObjectID Then
  628.                 pvtPersonsDataWrapper.MoveFirst
  629.             End If
  630.         End If
  631.         If tempUCaseEvent = "CHANGED" _
  632.         Then
  633.             pvtPersonsDataWrapper.Refresh
  634.             
  635.             pvtPersonsDataWrapper.FindFirst _
  636.                 "ObjectID = " & pvtCurrentPerson.ObjectID
  637.                
  638.             If Object.ObjectID = pvtCurrentPerson.ObjectID Then
  639.                 RefreshCustomerFields
  640.             End If
  641.         End If
  642.     End If
  643.     If tempObjectType = "Address" Then
  644.         RefreshAddressFields
  645.     End If
  646.     If tempObjectType = "Phone" Then
  647.         RefreshPhoneFields
  648.     End If
  649. End Sub
  650. Private Sub RefreshAddressFields()
  651.     On Local Error Resume Next
  652. ' map the selected Address to an Address in the
  653. '   Person.Addresses collection
  654.     Set pvtCurrentAddress = _
  655.         pvtCurrentPerson _
  656.             .Addresses _
  657.             (CStr(pvtAddressesDataWrapper.RecordSet("ObjectID")))
  658.     If pvtCurrentAddress Is Nothing Or Err = 3021 Then
  659.         efLine1 = ""
  660.         efLine2 = ""
  661.         efLine3 = ""
  662.         efCity = ""
  663.         lbxStateCodes = ""
  664.         efZipCode = ""
  665.         efZipSupplement = ""
  666.         efZipExtension = ""
  667.         efFormattedAddress = ""
  668.         Exit Sub
  669.     End If
  670.     efLine1 = pvtCurrentAddress.Line1
  671.     efLine2 = pvtCurrentAddress.Line2
  672.     efLine3 = pvtCurrentAddress.Line3
  673.     efCity = pvtCurrentAddress.City
  674.     lbxStateCodes = pvtCurrentAddress.State.StateCode
  675.     efZipCode = pvtCurrentAddress.ZipCode
  676.     efZipSupplement = pvtCurrentAddress.ZipSupplementString
  677.     efZipExtension = pvtCurrentAddress.ZipExtensionString
  678.     efFormattedAddress = pvtCurrentAddress.FormattedAddress
  679. End Sub
  680. Sub RefreshCustomerFields()
  681.     On Local Error Resume Next
  682. '    Set pvtCurrentPerson = _
  683. '        publicCompany _
  684. '            .Persons _
  685. '            (CStr(pvtPersonsDataWrapper.RecordSet("ObjectID")))
  686.         
  687. ' display the person's detail information
  688.     efCustomerNumber = pvtCurrentPerson.CustomerNumber
  689.     efFirstName = pvtCurrentPerson.FirstName
  690.     efLastName = pvtCurrentPerson.LastName
  691.     efSSN = pvtCurrentPerson.SSN
  692.     efDateOfBirth = Format$(pvtCurrentPerson.DateOfBirth, "mm/dd/yyyy")
  693.     lbxMaritalStatusCodes = pvtCurrentPerson.MaritalStatus
  694.     lbxGenderCodes = pvtCurrentPerson.Sex
  695.     efFormattedName = pvtCurrentPerson.FormattedName
  696.     efAge = pvtCurrentPerson.Age
  697. End Sub
  698. Private Sub RefreshPhoneFields()
  699.     On Local Error Resume Next
  700. ' map the selected Phone to a Phone in the
  701. '   Person.Phones collection
  702.     Set pvtCurrentPhone = _
  703.         pvtCurrentPerson _
  704.             .Phones _
  705.             (CStr(pvtPhonesDataWrapper.RecordSet("ObjectID")))
  706.     If pvtCurrentPhone Is Nothing Or Err = 3021 Then
  707.         efPhoneNumber = ""
  708.         efUsage = ""
  709.         efFormattedPhoneNumber = ""
  710.         Exit Sub
  711.     End If
  712.     efPhoneNumber = pvtCurrentPhone.PhoneNumber
  713.     efUsage = pvtCurrentPhone.Usage
  714.     efFormattedPhoneNumber = pvtCurrentPhone.FormattedPhoneNumber
  715. End Sub
  716. Private Sub RegisterForEvents()
  717. #If NoEventMgr = False Then
  718.     ObjectManager.RegisterForObjectEvent _
  719.         TriggerObjectType:="Person", _
  720.         RegisterObject:=Me, _
  721.         TriggerEvent:="Changed"
  722.     ObjectManager.RegisterForObjectEvent _
  723.         TriggerObjectType:="Address", _
  724.         RegisterObject:=Me, _
  725.         TriggerEvent:="Changed"
  726.     ObjectManager.RegisterForObjectEvent _
  727.         TriggerObjectType:="Phone", _
  728.         RegisterObject:=Me, _
  729.         TriggerEvent:="Changed"
  730. #End If
  731. End Sub
  732. Private Sub Data1_Validate(Action As Integer, Save As Integer)
  733.     pvtPersonsDataWrapper. _
  734.         Validate _
  735.             Action:=Action, _
  736.             Save:=Save
  737. End Sub
  738. Private Sub Data2_Reposition()
  739.     On Local Error Resume Next
  740.     Me.MousePointer = vbArrowHourglass
  741.         
  742.     Set pvtCurrentAddress = _
  743.         pvtAddressesDataWrapper. _
  744.             AbsolutePositionObject
  745.     RefreshAddressFields
  746.     Me.MousePointer = vbArrow
  747. End Sub
  748. Private Sub Data2_Validate(Action As Integer, Save As Integer)
  749.     pvtAddressesDataWrapper. _
  750.         Validate _
  751.             Action:=Action, _
  752.             Save:=Save
  753. End Sub
  754. Private Sub Data3_Reposition()
  755.     On Local Error Resume Next
  756.     Me.MousePointer = vbArrowHourglass
  757.         
  758.     Set pvtCurrentPhone = _
  759.         pvtPhonesDataWrapper. _
  760.             AbsolutePositionObject
  761.     RefreshPhoneFields
  762.     Me.MousePointer = vbArrow
  763. End Sub
  764. Private Sub Data3_Validate(Action As Integer, Save As Integer)
  765.     pvtPhonesDataWrapper. _
  766.         Validate _
  767.             Action:=Action, _
  768.             Save:=Save
  769. End Sub
  770. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  771.     Me.MousePointer = vbArrowHourglass
  772.     ObjectManager.Form_QueryUnload _
  773.         Me, _
  774.         pvtPersonsDataWrapper, _
  775.         pvtAddressesDataWrapper, _
  776.         pvtPhonesDataWrapper
  777. #If NoEventMgr = False Then
  778.     ObjectManager. _
  779.         UnRegisterForAllEvents _
  780.         RegisterObject:=Me
  781. #End If
  782.     Me.MousePointer = vbArrow
  783. End Sub
  784. Private Sub pbAddNewAddress_Click()
  785.     Dim tempNewAddress As New Address
  786.         
  787.     On Local Error Resume Next
  788.     Me.MousePointer = vbArrowHourglass
  789.     Set pvtCurrentAddress = tempNewAddress
  790.     PopulateCurrentAddress
  791.             
  792.     pvtCurrentPerson.AddAddress _
  793.         Item:=tempNewAddress
  794.         
  795.     pvtAddressesDataWrapper.Rebind _
  796.         Collection:=pvtCurrentPerson.Addresses
  797.     pvtAddressesDataWrapper.FindFirst _
  798.         "ObjectID = " & pvtCurrentAddress.ObjectID
  799.     Me.MousePointer = vbArrow
  800. End Sub
  801. Private Sub pbAddNewCustomer_Click()
  802.     Dim tempNewPerson As New Person
  803.         
  804.     On Local Error Resume Next
  805.     Me.MousePointer = vbArrowHourglass
  806.     Set pvtCurrentPerson = tempNewPerson
  807.     PopulateCurrentPerson
  808.         
  809.     publicCompany.AddPerson _
  810.         Item:=tempNewPerson
  811.         
  812.     Data2.Enabled = False
  813.     Data3.Enabled = False
  814.     pvtPersonsDataWrapper.Rebind _
  815.         Collection:=publicCompany.Persons
  816.     pvtPersonsDataWrapper.FindFirst _
  817.         "ObjectID = " & pvtCurrentPerson.ObjectID
  818.     Me.MousePointer = vbArrow
  819. End Sub
  820. Private Sub pbAddPhone_Click()
  821.     Dim tempNewPhone As New Phone
  822.         
  823.     On Local Error Resume Next
  824.     Me.MousePointer = vbArrowHourglass
  825.     Set pvtCurrentPhone = tempNewPhone
  826.     PopulateCurrentPhone
  827.             
  828.     pvtCurrentPerson.AddPhone _
  829.         Item:=tempNewPhone
  830.     pvtPhonesDataWrapper.Rebind _
  831.         Collection:=pvtCurrentPerson.Phones
  832.     pvtPhonesDataWrapper.FindFirst _
  833.         "ObjectID = " & pvtCurrentPhone.ObjectID
  834.     Me.MousePointer = vbArrow
  835. End Sub
  836. Private Sub pbDeleteAddress_Click()
  837.     On Local Error Resume Next
  838.     Me.MousePointer = vbArrowHourglass
  839.     Set pvtCurrentAddress = _
  840.         pvtCurrentPerson _
  841.             .Addresses _
  842.             (CStr(Data2.RecordSet("ObjectID")))
  843.            
  844.     pvtCurrentPerson.Addresses.Remove _
  845.         Item:=pvtCurrentAddress
  846.         
  847.     pvtAddressesDataWrapper.Rebind _
  848.         Collection:=pvtCurrentPerson.Addresses
  849.     pvtAddressesDataWrapper.MoveFirst
  850.     Me.MousePointer = vbArrow
  851. End Sub
  852. Private Sub pbDeleteCustomer_Click()
  853.     Dim saveObjectID As String
  854.     On Local Error Resume Next
  855.     Me.MousePointer = vbArrowHourglass
  856.     Set pvtCurrentPerson = _
  857.         publicCompany _
  858.             .Persons _
  859.             (CStr(pvtPersonsDataWrapper.RecordSet("ObjectID")))
  860.     publicCompany.Persons.Remove _
  861.         Item:=pvtCurrentPerson
  862.         
  863.     pvtPersonsDataWrapper.Rebind _
  864.         Collection:=publicCompany.Persons
  865.     pvtPersonsDataWrapper.MoveFirst
  866.     Me.MousePointer = vbArrow
  867. End Sub
  868. Private Sub pbDeletePhone_Click()
  869.     Dim saveObjectID As String
  870.     On Local Error Resume Next
  871.     Me.MousePointer = vbArrowHourglass
  872.     saveObjectID = CStr(pvtCurrentPhone.ObjectID)
  873.     With pvtCurrentPhone
  874.         .PhoneNumber = efPhoneNumber
  875.         .Usage = efUsage
  876.     End With
  877.     pvtCurrentPerson.Phones.Remove _
  878.         Item:=pvtCurrentPhone
  879.         
  880.     pvtPhonesDataWrapper.Rebind _
  881.         Collection:=pvtCurrentPerson.Phones
  882.     pvtPhonesDataWrapper.MoveFirst
  883.     Me.MousePointer = vbArrow
  884. End Sub
  885. Private Sub pbOK_Click()
  886.     Set pvtStates = Nothing
  887.     Set pvtGenderCodes = Nothing
  888.     Set pvtMaritalStatusCodes = Nothing
  889.     Unload Me
  890. End Sub
  891. Private Sub Data1_Reposition()
  892.         
  893.     On Local Error Resume Next
  894.     Me.MousePointer = vbArrowHourglass
  895.     Data2.Enabled = True
  896.     Data3.Enabled = True
  897.         
  898.     If pvtPersonsDataWrapper Is Nothing Then
  899.         Exit Sub
  900.     End If
  901.     Set pvtCurrentPerson = _
  902.         pvtPersonsDataWrapper. _
  903.             AbsolutePositionObject
  904.     RefreshCustomerFields
  905.     If pvtCurrentPerson Is Nothing Then
  906.         Data2.Enabled = False
  907.         Data3.Enabled = False
  908.         Me.MousePointer = vbArrow
  909.         Exit Sub
  910.     End If
  911. ' rebind the Wrappers for the contained
  912. '   collections
  913.     pvtAddressesDataWrapper.Rebind _
  914.         Collection:=pvtCurrentPerson.Addresses
  915.     pvtPhonesDataWrapper.Rebind _
  916.         Collection:=pvtCurrentPerson.Phones
  917. ' display details of the first Address
  918.     pvtAddressesDataWrapper.MoveFirst
  919. ' display details of the first Phone
  920.     pvtPhonesDataWrapper.MoveFirst
  921.     Me.MousePointer = vbArrow
  922. End Sub
  923. Private Sub Form_Load()
  924.     On Local Error Resume Next
  925.     PopulateStateCodes
  926.     PopulateGenderCodes
  927.     PopulateMaritalStatusCodes
  928.     Data2.Enabled = False
  929.     Data3.Enabled = False
  930.     Set pvtPersonsDataWrapper = _
  931.         ObjectManager. _
  932.             NewVBOFDataWrapper( _
  933.                 Collection:=publicCompany.Persons, _
  934.                 DataControl:=Data1)
  935.     Set pvtAddressesDataWrapper = _
  936.         ObjectManager. _
  937.             NewVBOFDataWrapper( _
  938.                 Collection:=Nothing, _
  939.                 DataControl:=Data2)
  940.                 
  941.     Set pvtPhonesDataWrapper = _
  942.         ObjectManager. _
  943.             NewVBOFDataWrapper( _
  944.                 Collection:=Nothing, _
  945.                 DataControl:=Data3)
  946.     pvtPersonsDataWrapper. _
  947.         MoveFirst
  948.     RegisterForEvents
  949. End Sub
  950. Private Sub pbUpdateAddress_Click()
  951. ' update the person's detail information
  952.     Dim saveObjectID As String
  953.         
  954.     On Local Error Resume Next
  955.     Me.MousePointer = vbArrowHourglass
  956.     PopulateCurrentAddress
  957.     pvtCurrentPerson.Addresses.Replace _
  958.         Item:=pvtCurrentAddress, _
  959.         ReplaceWith:=pvtCurrentAddress
  960.         
  961.     pvtAddressesDataWrapper.Rebind _
  962.         Collection:=pvtCurrentPerson.Addresses
  963.     pvtAddressesDataWrapper.FindFirst _
  964.         "ObjectID = " & pvtCurrentAddress.ObjectID
  965.     pvtCurrentAddress. _
  966.         ObjectHasChanged
  967.     Me.MousePointer = vbArrow
  968. End Sub
  969. Private Function PopulateCurrentAddress()
  970.     On Local Error Resume Next
  971.     With pvtCurrentAddress
  972.         .Line1 = efLine1
  973.         .Line2 = efLine2
  974.         .Line3 = efLine3
  975.         .City = efCity
  976.         .ZipCode = efZipCode
  977.         .ZipSupplement = efZipSupplement
  978.         .ZipExtension = efZipExtension
  979.     End With
  980.     Set pvtCurrentAddress.State = _
  981.         pvtStatesListBoxWrapper.ListIndexObject
  982. End Function
  983. Private Function PopulateCurrentPerson()
  984.     On Local Error Resume Next
  985.     With pvtCurrentPerson
  986.         .CustomerNumber = efCustomerNumber
  987.         .FirstName = efFirstName
  988.         .LastName = efLastName
  989.         .SSN = efSSN
  990.         .DateOfBirth = DateValue(efDateOfBirth)
  991.         .Sex = _
  992.             pvtGenderCodesListBoxWrapper. _
  993.                 ListIndexObject.GenderCode
  994.         .MaritalStatus = _
  995.             pvtMaritalStatusCodesListBoxWrapper. _
  996.                 ListIndexObject.MaritalStatusCode
  997.     End With
  998. End Function
  999. Private Function PopulateCurrentPhone()
  1000.     On Local Error Resume Next
  1001.     With pvtCurrentPhone
  1002.         .PhoneNumber = efPhoneNumber
  1003.         .Usage = efUsage
  1004.     End With
  1005. End Function
  1006. Private Sub PopulateStateCodes()
  1007. ' instantiate pvtStates as a reference
  1008. '   to pubStates
  1009.     Set pvtStates = _
  1010.         pubStates
  1011. ' attach the Collection, ListBox and ListBoxWrapper
  1012.     Set pvtStatesListBoxWrapper = _
  1013.         ObjectManager. _
  1014.             NewVBOFListBoxWrapper( _
  1015.             Collection:=pvtStates, _
  1016.             ListBox:=lbxStateCodes)
  1017.     pvtStatesListBoxWrapper. _
  1018.         AddItems
  1019. End Sub
  1020. Private Sub pbUpdateCustomer_Click()
  1021. ' update the person's detail information
  1022.         
  1023.     On Local Error Resume Next
  1024.     Me.MousePointer = vbArrowHourglass
  1025.     PopulateCurrentPerson
  1026.     publicCompany.Persons.Replace _
  1027.         Item:=pvtCurrentPerson, _
  1028.         ReplaceWith:=pvtCurrentPerson
  1029.         
  1030.     pvtPersonsDataWrapper.Rebind _
  1031.         Collection:=publicCompany.Persons
  1032.     pvtPersonsDataWrapper.FindFirst _
  1033.         "ObjectID = " & pvtCurrentPerson.ObjectID
  1034.         
  1035.     pvtCurrentPerson. _
  1036.         ObjectHasChanged
  1037.         
  1038.     Me.MousePointer = vbArrow
  1039. End Sub
  1040. Private Sub pbUpdatePhone_Click()
  1041. ' update the person's Phone information
  1042.     Dim saveObjectID As String
  1043.         
  1044.     On Local Error Resume Next
  1045.     Me.MousePointer = vbArrowHourglass
  1046.     PopulateCurrentPhone
  1047.             
  1048.     pvtCurrentPerson.Phones.Replace _
  1049.         Item:=pvtCurrentPhone, _
  1050.         ReplaceWith:=pvtCurrentPhone
  1051.     pvtPhonesDataWrapper.Rebind _
  1052.         Collection:=pvtCurrentPerson.Phones
  1053.     pvtPhonesDataWrapper.FindFirst _
  1054.         "ObjectID = " & pvtCurrentPhone.ObjectID
  1055.     pvtCurrentPhone. _
  1056.         ObjectHasChanged
  1057.         
  1058.     Me.MousePointer = vbArrow
  1059. End Sub
  1060.